<include file="Public:header" />
<link href="__PUBLIC__/css/litebox.css" rel="stylesheet" type="text/css">
<script src="__PUBLIC__/js/PCASClass.js" type="text/javascript"></script>
<script src="__PUBLIC__/js/docode.js" type="text/javascript"></script>
<!-- nice-scroll -->
<script src="__PUBLIC__/style/js/plugins/nice-scroll/jquery.nicescroll.min.js" type="text/javascript"></script>
<script type="text/javascript" src="__PUBLIC__/style/js/TableFreeze.js"></script>
<script src="__PUBLIC__/js/mxcrm_more.js" type="text/javascript"></script>
<!-- Select2 -->
<script src="__PUBLIC__/style/js/plugins/jsTree/jstree.min.js"></script>
<link href="__PUBLIC__/style/css/plugins/jsTree/style.min.css" rel="stylesheet">
<style>
    body{
        overflow-y: hidden;
    }
    .option{padding-left:-30px;}
    #oDivL_tab_Test3{background-color: #fff;}
    .status_ico{
        position: absolute;
        top: -46px;
        background: #FFF;
        border: 1px solid #AAA;
        border-radius: 5px;
        padding: 7px;
        width: 220px;
        display: inline-block;
        display: none;
        left: 50%;
        margin-left: -159px;
        z-index: 101;
    }
    .status_ico:before {
        content: "";
        width: 0;
        height: 0;
        border-left: 10px solid transparent;
        border-right: 10px solid transparent;
        border-top: 10px solid #AAA;
        position: absolute;
        bottom: -10px;
        left: 100px;
    }
    .status_ico:after{
        content: "";
        width: 0;
        height: 0;
        border-left: 9px solid transparent;
        border-right: 9px solid transparent;
        border-top: 9px solid #FFF;
        position: absolute;
        bottom: -9px;
        left: 101px;
    }
    .LocalDataUIB{
        margin-left: -4px;
    }
    .LocalDataUIB-input{
        left: 5px;
    }
</style>
<script>
    $(function(){
        var scroll_width = 10;
        $("#table_div").height(window.innerHeight-$("#table_div").offset().top-$("#tfoot_div").height()-parseInt($("#table_container").css("padding-bottom").replace("px",""))-10);
        $(window).resize(function(){
            $("#table_div").height(window.innerHeight-$("#table_div").offset().top-$("#tfoot_div").height()-parseInt($("#table_container").css("padding-bottom").replace("px",""))-10);
            $("#oDivL_tab_Test3").height($("#table_div").height()-1).width($("#oTableLH_tab_Test3").width());
            $("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width());
        })
        $(".nicescroll").niceScroll({
            cursorcolor: "#999",//#CC0071 光标颜色
            cursoropacitymax: 0.4, //改变不透明度非常光标处于活动状态（scrollabar“可见”状态），范围从1到0
            touchbehavior: false, //使光标拖动滚动像在台式电脑触摸设备
            cursorwidth: scroll_width+"px", //像素光标的宽度
            cursorborder: "0", //     游标边框css定义
            cursorborderradius: "3px",//以像素为光标边界半径
            autohidemode: false, //是否隐藏滚动条
            zindex:100,
            background:"#F3F3F5",//滚动条背景色
        });
        $("#tab_Test3").FrozenTable(1,0,3);
        $("#oDivL_tab_Test3").height($("#table_div").height()-scroll_width-1).width($("#oTableLH_tab_Test3").width()).css({'zIndex':9});
        $("#oDivL_tab_Test3").css({"background-color":"#fff","border-right":"1px solid #e7eaec"});
        $("#oTableLH_tab_Test3").css({"border-right":"1px solid #e7eaec"});
        $("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width()-scroll_width).css({'zIndex':9});

        $("#left_list").height(window.innerHeight-$("#left_list").offset().top-30);
        $(window).resize(function(){
            $("#left_list").height(window.innerHeight-$("#left_list").offset().top-30);
        })
    })
</script>
<div style="display:none" id="dialog-log" title="加入项目">
    <div class="spiner-example">
        <div class="sk-spinner sk-spinner-three-bounce">
            <div class="sk-bounce1"></div>
            <div class="sk-bounce2"></div>
            <div class="sk-bounce3"></div>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content">
    <include file="Public:alert" />
    <div class="row">
        <div class="col-md-12">
            <div class="ibox float-e-margins">
                <div class="title-bar" style="position: relative;z-index: 99;">
                    <div class="row  clearfix" id="title-hide" style="display:none;">
                        <ul class="breadcrum pull-left">
                            <li>已选中&nbsp;<span id="icheck_num"></span>&nbsp;项</li>
                            <li>
                                <!--<span><a href="javascript:void(0);" class="link excelExport"><i class="fa fa-download"></i>&nbsp;导入</a></span>-->
                            </li>
                            <li class="last_li"><big><a class="fa fa-times pull-right" id="back-show"></a></big></li>
                        </ul>
                    </div>
                    <div class="row " id="title-show">

                        <form class="form-inline" id="" action="" method="get">
                            <ul class="breadcrum pull-right" style="margin-bottom: 0px">

                                <div class="btn-group ">
                                    <button data-toggle="dropdown" class="btn btn-primary dropdown-toggle" aria-expanded="false">操作 <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu">
                                        <li><a id="import_excel" class="link" href="javascript:void(0);"><i class="fa fa-upload"></i>&nbsp;导入</a></li>
                                        <!--<li><a href="javascript:void(0);" class="link excelExport"><i class="fa fa-download"></i>&nbsp;导出</a></li>-->
                                    </ul>
                                    </div>
                                </ul>
                            </form>



                            <form id="searchForm" class="form-group" method="get" style="margin-bottom: 0px;">
                                <input type="hidden" name="m" value="integral" />
                                <input type="hidden" name="a" value="index" />
                                <div class="nav pull-left" style="margin:2px 0 0 15px;width: 165px;">
                                    <div class="input-group">
                                        <select class="form-control select2" style="min-width:165px;max-width: 165px;height: 0px;" name="position_info" id="position_info" >
                                            <option class="all" value="all">--请选择升降级状态--</option>
                                            <option class="all" value="0" <if condition="($_GET['position_info'] eq 0) and is_numeric($_GET['position_info'])">selected</if>>正常</option>
                                            <option class="all" value="1" <if condition="$_GET['position_info'] eq 1">selected</if>>升级</option>
                                            <option class="all" value="-1" <if condition="$_GET['position_info'] eq -1">selected</if>>降级</option>
                                        </select>
                                    </div>
                                </div>
                                <if condition = "$_GET['dbname'] eq ''">
                                    <div class="nav pull-left" style="margin:2px 0 0 15px;width: 165px;">
                                        <div class="input-group">
                                            <select class="form-control select2" style="min-width:165px;max-width: 165px;height: 0px;" name="department" id="department" onchange="changeRole()">
                                                <option class="all" value="all">{:L('ALL')}</option>
                                                <volist name="departmentList" id="vo">
                                                    <option value="{$vo.department_id}" <if condition="$_GET['department'] eq $vo['department_id']">selected</if>>{$vo.name}</option>
                                                </volist>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="nav pull-left" style="margin:2px 0 0 15px;width: 165px;">
                                        <div class="input-group">
                                            <select class="form-control select2" style="min-width:165px;max-width: 165px;height: 0px;" name="role" id="role" onchange="changeCondition()">
                                                <option class="all" value="all">{:L('ALL')}</option>
                                                <volist name="roleList" id="vo">
                                                    <option value="{$vo.role_id}" <if condition="$_GET['role'] eq $vo['role_id']">selected</if>>{$vo.role_name}-{$vo.user_name}</option>
                                                </volist>
                                            </select>
                                        </div>
                                    </div>
                                </if>
                                <div class="pull-left" style="margin-left: 20px;">
                                    <button type="submit" id="analytics_search" class="btn btn-primary">立即搜索</button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <div class="row" style="margin: 0;">
                        <div class="pull-left" style="width:16.222%;color: #000;display: none;">
                            <div class="ibox-title clearfix" style="padding-top: 4px;">
                                <div class="detail-title clearfix">
                                    <div class="pull-left all-inline">
                                        <a href="{:U('product/index')}">
                                            <span class="fa fa-inbox" style="font-size:18px;color:#667B8F"></span>&nbsp;
                                            <span style="color:#667B8F">全部人才</span>
                                        </a>
                                    </div>
                                </div>
                            </div>
                            <div class="ibox-content" style="min-height: 300px;border-top: none;">
                                <div id="left_list" class="full-height-scroll">
                                    <div id="knowledge-tree" >
                                        {$tree_code}
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="pull-right" style="width:100%">
                            <div class="ibox-content clearfix" id="table_container" style="z-index: 1;">
                                <form id="form1" action="" method="Post" style="position:relative;">
                                    <div id="table_div" class="nicescroll">
                                        <table class="table table-hover table-striped table_thead_fixed" id="tab_Test3">
                                            <if condition="$list eq null">
                                                <div style="background-color:#fff;"><include file="Public:nodata" /></div>
                                                <else/>
                                                <tr id="childNodes_num" class="tabTh">
                                                    <td style="max-width: 60px;width:74px;padding:0 10px 0 7px;">
                                                        <div class="checkbox checkbox-primary">
                                                            <input type="checkbox" class="check_all"/>
                                                            <label for=""></label>
                                                        </div>
                                                    </td>

                                                    <td>姓名</td>
                                                    <td>部门</td>
                                                    <td>职级</td>
                                                    <volist name="month_num" id="vo">
                                                        <td>{$vo}</td>
                                                    </volist>

                                                    <td>升降级提示</td>
                                                    <!--<td>当月工资计算</td>-->
                                                    <!--<td>操作</td>-->
                                                </tr>
                                                <tbody>
                                                <volist name="list" id="vo">
                                                    <tr class="controls_tr">
                                                        <td>
                                                            <div class="checkbox checkbox-primary">
                                                                <input name="product_id[]" class="check_list" type="checkbox" value="{$vo.eid}" <if condition="$vo['is_deleted'] eq '0'">rel1="0"<else/>rel1="1"</if>/>
                                                                <label for=""></label>
                                                            </div>
                                                        </td>
                                                       <td>{$vo.full_name}</td>
                                                       <td>{$vo.department_name}</td>
                                                       <td>{$vo.rank_name}</td>
                                                       <volist name="month_yj" id="v">
                                                       <td>{$vo[$v]}</td>
                                                       </volist>
                                                       <td>
                                                           <if condition="$vo['position_info'] eq -1"><a class="label label-danger jjstatus" style="color: white;" data-id="{$vo['user_id']}">降级 </a>
                                                           <elseif condition="$vo['position_info'] eq 1"/><a class="label label-primary sjstatus" style="color: white;" data-id="{$vo['user_id']}">升级 </a>
                                                           <else/>
                                                               正常
                                                           </if>
                                                       </td>
                                                       <!--<td>10</td>-->
                                                    </tr>
                                                </volist>
                                                <tbody>
                                            </if>
                                        </table>
                                    </div>
                                    <div id="tfoot_div" class="clearfix">
                                        <div class="clearfix" id="tfoot_page">
                                            <if condition="$fields_search || $_GET['field']">
                                                <span class="pull-left" style="margin-left:25px;margin-top:10px;">本次搜索结果<span style="color:#F8AC59"> {$count} </span>条数据<a href="{:U('product/index')}" class="btn" style="background:#fff;border:1px solid #ccc;margin-left:10px;color:#999;" id="clearnumber">清除搜索条件</a></span>
                                            </if>
                                            {$page}<include file="Public:listrows" />
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

<div class="" style="display:none;" id="dialog-import" title="导入数据">
    <div class="spiner-example">
        <div class="sk-spinner sk-spinner-three-bounce">
            <div class="sk-bounce1"></div>
            <div class="sk-bounce2"></div>
            <div class="sk-bounce3"></div>
        </div>
    </div>
</div>
<div class="" style="display:none;" id="dialog-role-info" title="{:L('EMPLOYEE_INFORMATION')}">
    <div class="spiner-example">
        <div class="sk-spinner sk-spinner-three-bounce">
            <div class="sk-bounce1"></div>
            <div class="sk-bounce2"></div>
            <div class="sk-bounce3"></div>
        </div>
    </div>
</div>
<script src="__PUBLIC__/js/images-loaded.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/js/litebox.min.js" type="text/javascript"></script>
<link href="__PUBLIC__/css/litebox.css" rel="stylesheet">


<script type="text/javascript">


    /*让复选框默认取消选择*/
    $(':checkbox').prop('checked', false);


    $(".controls_tr").mouseenter(function(){
        $(this).find(".controls").show();
    }).mouseleave(function(){
        $(this).find(".controls").hide();
    });
    var url = "{:U('product/getcurrentstatus')}";
    var limit_size = 1000;
    var count = '{$count}';

    var ii = 1;



    if ("{:C('isMobile')}" == "1") {
        width = $('.container').width() * 0.9;
    } else {
        width = 800;
    }

    $("#dialog-role-info").dialog({
        autoOpen: false,
        modal: true,
        width: width,
        maxHeight: 550,
        position: ["center",100]
    });
    $("#dialog-import").dialog({
        autoOpen: false,
        modal: true,
        width: width,
        maxHeight: 400,
        position: ["center",100]
        // buttons: {
        // 	"确定": function () {
        // 		$('#excelimport_dialog').submit();
        // 		$(this).dialog("close");
        // 	},
        // 	"取消": function () {
        // 		$(this).dialog("close");
        // 	}
        // }
    });

    /*添加筛选条件*/
    var m = 1;
    $('#add_btn').click(function(){
        m += 1;
        $('#search_add').append('<div id="con_search_'+m+'" style="float:left;width:650px;padding-top:10px;margin:0px 10px 0 10px;"><div  id="rem_'+m+'" class="pull-left" style="line-height:30px;"><a href="javascript:void(0);" class="rem_search" rel="'+m+'" title="移除"><span class="fa fa-times-circle"></span></a></div>&nbsp;<ul class="nav pull-left" style="margin:0px 0 0 5px;width:620px"><li class="pull-left"><select id="field_'+m+'"  style="width:auto" class="form-control input-sm field_name new-select" onchange="changeCondition('+m+')" name=""><option class="" value="name">--请选择筛选条件--</option><volist name="field_list" id="v"><if condition = "$v['form_type'] eq 'p_box' && $v['field'] eq 'category_id'"><option class="product_category" value="{$v[field]}" rel="product" >{$v[name]}</option><else /><option class="{$v['form_type']}" value="{$v['field']}" rel="product" <if condition = "$vo['field'] eq $v['field']">selected="selected"</if>>{$v[name]}</option></if></volist><option class="role" value="owner_role_id">{:L('PRINCIPAL')}</option><option class="date" value="create_time">{:L('CREATION_TIME')}</option><option class="date" value="update_time">{:L('MODIFICATION_TIME')}</option></select>&nbsp;&nbsp;</li><li class="pull-left" id="conditionContent_'+m+'"><select id="condition_'+m+'" style="width:auto" class="form-control input-sm new-select" name="condition" onchange="changeSearch()"><option value="contains">{:L('INCLUDE')}</option><option value="not_contain">不包括</option><option value="is">{:L('YES')}</option><option value="isnot">{:L('ISNOT')}</option><option value="start_with">{:L('BEGINNING_CHARACTER')}</option><option value="end_with">{:L('TERMINATION_CHARACTER')}</option><option value="is_empty">{:L('Mandatory')}</option><option value="is_not_empty">不为空</option></select>&nbsp;&nbsp;</li><li class="pull-left" id="searchContent_'+m+'"><input id="search_'+m+'" type="text" style="width:160px;" class="input-medium form-control input-sm search-query" name="search"/>&nbsp;&nbsp;</li></ul></div>');
    });
    $(document).on('click','.rem_search',function(){
        var num = $(this).attr('rel');
        $('#con_search_'+num).remove();
    });

    // 筛选重复判断
    var dosearch = 1;
    function doh(){
        var ary = new Array();
        var field_name = '';
        var is_submit = 1;
        $('.field_name').each(function(k, v){
            field_name = $(this).find("option:selected").val();
            if(jQuery.inArray(field_name,ary) >= 0){
                is_submit = 0;
                swal({
                    title: "筛选条件中有重复项！",
                    text: data.info,
                    type: "error"
                });
                dosearch = 0;
                return false;
            }
            ary[k] = field_name;
        })
        if(is_submit == 1){
            $("#searchForm").submit();
        }
    }

    $("#dialog-field-search").dialog({
        autoOpen: false,
        modal: true,
        width: 750,
        height: 500,
        position: ["center",100],
        buttons: {
            "确定": function () {
                doh();
                if(dosearch == 1){
                    $(this).dialog("close");
                }
            },
            "取消": function () {
                $(this).dialog("close");
            }
        }
    });
    $("#search_type").click(function(){
        $("#dialog-field-search").dialog('open');
    });

    $('.sjstatus').click(function () {
        var _this = $(this);
        swal({
                title: "确定对该员工升级职级吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                closeOnConfirm: false
            },
            function () {
                var user_id = _this.attr("data-id");
                $.ajax({
                    type: "post",
                    url: "{:U('integral/position_edit')}",
                    data: {
                        user_id: user_id,
                        position_info: 1
                    },
                    success: function (data) {
                        if (data.status == 1) {
                            location = location;
                        }
                    }
                })
            });
    });
    $('.jjstatus').click(function () {
        var _this = $(this);
        swal({
                title: "确定对该员工降级职级吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                closeOnConfirm: false
            },
            function () {
                var user_id = _this.attr("data-id");
                $.ajax({
                    type: "post",
                    url: "{:U('integral/position_edit')}",
                    data: {
                        user_id: user_id,
                        position_info: -1
                    },
                    success: function (data) {
                        if (data.status == 1) {
                            location = location;
                        }
                    }
                });
            });
    });


    var limit_size = 1000;
    var ii = 1;
    var count = '{$count}';
    $(".excelExport").click(function(){
        if(ii == -1){
            ii = 1;
        }
        var id_array = new Array();
        $("input.check_list:checked").each(function() {
            id_array.push($(this).val());
        });
        if(id_array){
            $("#daochu").val(id_array);
        }
//        alert(id_array);
        $("#act").val('excel');
        $("#current_page").val(ii);
        $("#export_limit").val(limit_size);
        $("#searchForm").submit();
    })

    $("#dosearch").click(function () {
        result = checkSearchForm();
        if (result) {
            $("#act").val('search');
            $("#searchForm").submit();
        }
    });

    $("#import_excel").click(function () {
        $('#dialog-import').dialog('open');
        $('#dialog-import').load('{:U("integral/excelimport")}');
    });
    $(".role_info").click(function () {
        $role_id = $(this).attr('rel');
        $('#dialog-role-info').dialog('open');
        $('#dialog-role-info').load('{:U("user/dialoginfo","id=")}' + $role_id);
    });

    //编辑人才状态效果
    $(function () {
        //点击效果
        $(".editstatus").click(function () {
            $(".status_ico").hide();
            $(this).next().show();
        })
        //点击确认按钮修改状态
        $(".status_btnedit").click(function () {
            var product_id=parseInt($(this).closest("tr").find(".check_list").val());
            var status=$(this).closest(".editable-controls").find("select option:selected").val();
            $.ajax({
                type: "post",
                url:"/index.php?m=product&a=editstatus&id="+product_id,
                data:{
                    product_id:product_id,
                    status:status
                },
                success:function (data) {
                    console.log(data);
                    swal("温馨提示！", "状态修改成功！", "success");
                    window.location=location;

                },
                error:function () {

                }
            })
        })
    })

    $(document).click(function(e){
        var _con = $('.editstatus,.editable-controls select');   // 设置目标区域
        if(!_con.is(e.target) && _con.has(e.target).length === 0){
            $(".status_ico").hide();
        };
    });


    $(".log_calllist").click(function(){
        $('#dialog-log').dialog('open');
        $('#dialog-log').load('{:U("log/resume_project","r=RCustomerLog&module=customer&id=")}'+$(this).attr('rel'));
        $.fn.modal.Constructor.prototype.enforceFocus = function() {};
    });


    $("#dialog-log").dialog({
        autoOpen: false,
        // modal: true,
        width: 750,
//    minHeight: 300,
        maxHeight: 500,
        position: ["center",100],
        buttons: {
            "确定": function () {

                $.ajax({
                    type:'post',
                    url: "{:U('Log/add_fine_project')}",
                    data:$('#dialog_form1').serialize(),
                    async: false,
                    success: function (data) {
                        if (data.status == 1) {
                            swal("操作成功！", "该人选成功加入项目！", "success");
                            $("#dialog-log").dialog("close");
                            // location.reload();
                        } else {
                            swal({
                                title: "操作失败！",
                                text:data.info,
                                type: "error"
                            });
                            return false;
                        }
                    },
                    dataType: 'json'
                });
            },
            "取消": function () {
                $(this).dialog("close");
            }
        },
        close: function() {
            $(this).html('');
        }
    });

    $(".select2").select2();

    var limit_size = 1000;
    var ii = 1;
    var count = '{$count}';
    $(".excelExport").click(function(){
        if(ii == -1){
            ii = 1;
        }
        var id_array = new Array();
        $("input.check_list:checked").each(function() {
            id_array.push($(this).val());
        });
        if(id_array){
            $("#daochu").val(id_array);
        }
//        alert(id_array);
        $("#act").val('excel');
        $("#current_page").val(ii);
        $("#export_limit").val(limit_size);
        $("#searchForm").submit();
    })

    function changeRole(){
        department_id = $("#department option:selected").val();
        $.ajax({
            type:'get',
            url:'index.php?m=user&a=getrolebydepartment&department_id='+department_id,
            async:true,
            success:function(data){
                options = '<option value="all">{:L('ALL')}</option>';
                if(data.data != null){
                    $.each(data.data, function(k, v){
                        options += '<option value="'+v.role_id+'">'+v.role_name+"-"+v.user_name+'</option>';
                    });
                }
                $("#role").html(options);
            <if condition="$_GET['role']">
                    $("#role option[value='{$Think.get.role}']").prop("selected", true);
            </if>
            },
            dataType:'json'});
    }
</script>
<include file="Public:footer" />


<div id="right-sidebar-log">
    <!--the css for jquery.mCustomScrollbar-->
    <link rel="stylesheet" href="__PUBLIC__/emoji/css/jquery.mCustomScrollbar.min.css"/>
    <!--the css for this plugin-->
    <link rel="stylesheet" href="__PUBLIC__/emoji/css/jquery.emoji.css"/>
    <!--(Optional) the js for jquery.mCustomScrollbar's addon-->
    <script src="__PUBLIC__/emoji/js/jquery.mousewheel-3.0.6.min.js"></script>
    <!--the js for jquery.mCustomScrollbar-->
    <script src="__PUBLIC__/emoji/js/jquery.mCustomScrollbar.min.js"></script>
    <!--the js for this plugin-->
    <script src="__PUBLIC__/emoji/js/jquery.emoji.js"></script>

    <div class="sidebar-container" id="sidebar-container">

    </div>
</div>
<style>
    .slimScrollDiv{
        overflow: inherit !important;
    }

    .sidebar-container ul.nav-tabs li a{
        background: #fff !important;
        color: #a7b1c2 !important;
        font-weight: 600 !important;
        padding: 14px 20px 14px !important;
        border-right: none !important;
    }
    .sidebar-container nav{
        display: none;
    }
    .sidebar-container #page-wrapper{
        margin-left: 0px;
    }
    #sidebar-container{
        box-shadow: rgb(187, 187, 187) -1px 10px 10px;
        border: 2px solid rgb(238, 238, 238);
    }

    #right-sidebar-log{
        width: 60%;
        right: -60%;
        background-color: #fff;
        position: fixed;
        top: 60px;
        z-index: 1009;
        bottom: 0;
        box-shadow: -5px -5px 1px #ccc;
    }

</style>
